package com.ljb.android.comm.img.ktx

import android.graphics.Bitmap
import com.ljb.android.comm.img.core.BitmapListener

open class BaseBitmapListener : BitmapListener {

    private var mOnSuccessEx: ((Bitmap) -> Unit)? = null
    private var mOnErrorEx: (() -> Unit)? = null

    override fun onBitmapSuccess(bitmap: Bitmap) {
        mOnSuccessEx?.invoke(bitmap)
    }

    override fun onBitmapError() {
        mOnErrorEx?.invoke()
    }

    //以下代码提供Kotlin Lambda使用
    fun onBitmapError(error: () -> Unit) {
        mOnErrorEx = error
    }

    fun onBitmapSuccess(success: (Bitmap) -> Unit) {
        mOnSuccessEx = success
    }

}